package com.kedacom.freedomLabel.label.annotation;

import java.math.BigInteger;

/**
 * Author：李程
 * CreateTime：2020/4/25 20:25
 * E-mail：licheng@kedacom.com
 * Describe：
 */
public final class OriginalOptions {

    /**
     * 标签尺寸起始符
     */
    public static final int STX_SIZE = 'P';

    /**
     * 文本起始符
     */
    public static final int STX_TEXT = 'A';

    /**
     * 线条起始符
     */
    public static final int STX_LINE = 'L';

    /**
     * 一维码起始符
     */
    public static final int STX_HR = 'B';

    /**
     * 二维码起始符
     */
    public static final int STX_QR = bytesToInt("QR".getBytes());

    /**
     * 图片起始符
     */
    public static final int STX_BITMAP = 'G';

    public static OriginalFontConfig.ROTATION getOriginalFontRotation(int rotation) {
        if (rotation == OriginalFontConfig.ROTATION.ROTATION_0.getValue()) {
            return OriginalFontConfig.ROTATION.ROTATION_0;
        }
        if (rotation == OriginalFontConfig.ROTATION.ROTATION_90.getValue()) {
            return OriginalFontConfig.ROTATION.ROTATION_90;
        }
        if (rotation == OriginalFontConfig.ROTATION.ROTATION_180.getValue()) {
            return OriginalFontConfig.ROTATION.ROTATION_180;
        }
        if (rotation == OriginalFontConfig.ROTATION.ROTATION_270.getValue()) {
            return OriginalFontConfig.ROTATION.ROTATION_270;
        }
        return OriginalFontConfig.ROTATION.ROTATION_0;
    }

    public static OriginalFontConfig.STYLE getOriginalFontStyle(int style) {
        if (style == OriginalFontConfig.STYLE.NORMAL.getValue()) {
            return OriginalFontConfig.STYLE.NORMAL;
        }
        if (style == OriginalFontConfig.STYLE.INVERSE.getValue()) {
            return OriginalFontConfig.STYLE.INVERSE;
        }
        if (style == OriginalFontConfig.STYLE.BOLD.getValue()) {
            return OriginalFontConfig.STYLE.BOLD;
        }
        if (style == OriginalFontConfig.STYLE.INVERSE_BOLD.getValue()) {
            return OriginalFontConfig.STYLE.INVERSE_BOLD;
        }
        return OriginalFontConfig.STYLE.NORMAL;
    }

    public static int bytesToInt(byte[] data) {
        return new BigInteger(1, data).intValue();
    }
}
